Public Suffix for Ruby

The gem public_suffix is a domain name parser, written in Ruby, and based on the Public Suffix List.

The library is trusted by several large companies and applications, including GitHub pages (via github-pages-health-check) and DNSimple.

Usage

PublicSuffix.domain("google.com")
# => "google.com"
PublicSuffix.domain("www.google.com")
# => "google.com"
PublicSuffix.domain("www.google.co.uk")
# => "google.co.uk"

# Parse the domain into its components
PublicSuffix.parse("www.google.com")
# => #<PublicSuffix::Domain:0x000000 @tld="com", @sld="google", @trd="www">